package com.lwb.ztx.videos.presenter;

import com.lwb.ztx.bean.VideoBean;
import com.lwb.ztx.bean.VideoMainBean;
import com.lwb.ztx.videos.model.VideoModel;
import com.lwb.ztx.videos.model.VideoModelImpl;
import com.lwb.ztx.videos.view.VideoView;

import java.util.List;

/**
 * Created by luweibin on 2016/5/30.
 */
public class VideoPresenterImpl implements VideoPresenter,VideoModelImpl.OnVideoLoadFinishListener {
    VideoModel videoModel;
    VideoView videoView;

    public VideoPresenterImpl(VideoView videoView) {
        videoModel = new VideoModelImpl(this);
        this.videoView = videoView;
    }

    @Override
    public void getVideos(String url,int page) {
        videoModel.loadVideos(url,page);
    }

    @Override
    public void getMoreVideos(String url,int page) {
        videoModel.loadVideos(url,page);
    }

    @Override
    public void onSuccess(VideoMainBean bean, int page) {
        if(page > 1) {
            videoView.addMoreVideos(bean);
        } else {
            videoView.setVideos(bean);
        }
    }

    @Override
    public void onFailure() {

    }
}
